package com.crm.jpaandthymeleaf.service.impl;

import com.crm.jpaandthymeleaf.service.PasswordService;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @author 周敬
 * @version 1.0
 * @packageName com.crm.jpaandthymeleaf.service.impl
 * @fileName PasswordServiceImpl
 * @createTime 2022/1/4-16:17-星期二
 * @lastModify 2022/1/4-16:17-星期二
 */
@Service
public class PasswordServiceImpl implements PasswordService {

    @Value("${redis.hash.algorithm}")
    private String hashAlgorithm;
    @Value("${redis.hash.count}")
    private int hashCount;

    /**
     * 对密码进行加密
     *
     * @param usrName
     * @param usrPassword
     * @return
     */
    @Override
    public String encryptPassword(String usrName, String usrPassword) {
        SimpleHash simpleHash = new SimpleHash(hashAlgorithm,usrPassword,usrName,hashCount);
        return simpleHash.toString();
    }
}
